//当前这个模块：API进行统一管理

import requests from "./request.js";
import mock from "./mock.js"

//三级联动接口
// 接口 /api/product/getBaseCategoryList      get 无参数
//发请求：axios发请求返回结果Promise对象
//例子
export const reqCategoryList = () => {
  return requests({
    //请求路径
    url: "/product/getBaseCategoryList",
    //请求方式
    method: "get",
  });
};
//获取banner(Home首页轮播图接口)
export const reqCetBannerList = () => {
  return mock({
    //请求路径
    url: "/banners",
    //请求方式
    method: "get",
  });
};
//获取floors(Home首页轮播图接口)
export const reqCetFloorsList = () => {
  return mock({
    //请求路径
    url: "/floors",
    //请求方式
    method: "get",
  });
};
//获取搜索页面数据 post请求需要带参数
/*
请求地址 /api/list 请求方式 POST
{
  "category3Id": "61",
  "categoryName": "手机",
  "keyword": "小米",
  "order": "1:desc",
  "pageNo": 1,
  "pageSize": 10,
  "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
  "trademark": "4:小米"
}
*/
export const reqcatSearchInfo = (params)=>{
  return requests({
    //请求路径
    url : "/list",
    //请求方式
    method : "post",
    // 数据
    data : params,
  })
};
//获取详情页面数据 get请求需要带参数
//地址 /api/item/{ skuId }
export const reqGoodsInfo = (skuId) => {
  return requests({
    url:`/item/${skuId}`,
    method:"get"
  })
};
//获取添加到购物车
export const reqAddToCart = (skuId,skuNum) =>{
  return requests({
    url:`/cart/addToCart/${skuId}/${skuNum}`,
    method:"post",
  })
};
//获取购物车
export const reqGetShopCart = () =>{
  return requests({
    url:"/cart/cartList",
    method:"get"
  })
};
//删除指定商品 /cart/deleteCart/{skuId} 请求方式 DELETE
export const reqDeleteCart = (skuId)=>{
  return requests({
    url:`/cart/deleteCart/${skuId}`,
    method:"delete",
  })
}
//切换商品选中状态 /cart/checkCart/{skuID}/{isChecked} 请求方式 get
export const reqCheckCart = (skuId,isChecked)=>{
  return requests({
    url:`/cart/checkCart/${skuId}/${isChecked}`,
    method:"get"
  })
}
//获取验证码 /user/passport/code 请求方式get
export const reqVerifIcation = (phone)=>{
  return requests({
    url:`/user/passport/sendCode/${phone}`,
    method:"get"
  })
}
//注册用户 /user/passport/register 请求方式post 参数：phone password code
export const reqPassport = (params) =>{
  return requests({
    url : "/user/passport/register",
    method : "post",
    data : params,
  })
}
//登录 /user/passport/login 请求方式post 参数 phone password
export const reqLogin =(data)=>{
  return requests({
  url:"/user/passport/login",
  method:"post",
  data,

  })
}
//获取用户信息 /user/passport/auth/getUserInfo 请求方式 get
export const reqUserInfo =()=>{
  return requests({
    url:"/user/passport/auth/getUserInfo",
    method:"get"
  })
}
//退出登录  /user/passport/logout 请求方式 GET
export const reqLongOut =()=>{
  return requests({
    url:"/user/passport/logout",
    method:"get"
  })
}

//获取订单信息 /order/auth/trade 请求方式 get
export const reqTradeInfo = ()=>{
  return requests({
    url:"/order/auth/trade",
    method:"get",
  })
}
//获取用户地址信息 /user/userAddress/auth/findUserAddressList 请求方式 get
export const reqfindUserAddressList =()=>{
  return requests({
    url:"/user/userAddress/auth/findUserAddressList",
    method:"get"
  })
}
//提交订单 /order/auth/submitOrder?tradeNo={tradeNo} 请求方式post
export const reqSubmitOrder = (data)=>{
  return requests({
    url:`/order/auth/submitOrder?tradeNo=${data.traderNo}`,
    method:'post',
    data,
  })
}
//获取订单支付信息 /payment/weixin/createNative/{orderId} 请求方式 get
export const reqCreateNative =(data)=>{
  return requests({
    url:`/payment/weixin/createNative/${data}`,
    method:'get',
    data,
  })
}
//查询支付订单状态 /payment/weixin/queryPayStatus/{orderId} 请求方式 get
export const reqQueryPayStatus = (data)=>{
  return requests({
    url:`/payment/weixin/queryPayStatus/${data}`,
    method:"get",
    data,
  })
}


